home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / wv2 / wvlog.h < prev   
Encoding:
C/C++ Source or Header  |  2006-06-12  |  5.6 KB  |  111 lines

  1. /* This file is part of the wvWare 2 project
  2.    Copyright (C) 2003 Werner Trobin <trobin@kde.org>
  3.  
  4.    This library is free software; you can redistribute it and/or
  5.    modify it under the terms of the GNU Library General Public
  6.    License version 2 as published by the Free Software Foundation.
  7.  
  8.    This library is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  11.    Library General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU Library General Public License
  14.    along with this library; see the file COPYING.LIB.  If not, write to
  15.    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16.    Boston, MA 02111-1307, USA.
  17. */
  18.  
  19. #ifndef WVLOG_H
  20. #define WVLOG_H
  21.  
  22. #include <iostream>
  23. #include <string>     // Make gcc 2.95.x happy
  24.  
  25. /**
  26.  * @file A very primitve logging mechanism used to disable any
  27.  * debug output for release builds. Use it like std::cerr, as it
  28.  * is std::cerr (if it's enabled).
  29.  */
  30. namespace wvWare
  31. {
  32.  
  33.     class wvdebugstream
  34.     {
  35.     public:
  36. #if defined(__GNUC__) && __GNUC__ < 3
  37.         const wvdebugstream& operator<<( ostream& (*__pf)( ostream& ) ) const { std::cerr << __pf; return *this; }
  38.         const wvdebugstream& operator<<( ios (*__pf)( ios& ) ) const { std::cerr << __pf; return *this; }
  39. #else
  40.         const wvdebugstream& operator<<( std::basic_ostream<char>& (*__pf)( std::basic_ostream<char>& ) ) const { std::cerr << __pf; return *this; }
  41.         const wvdebugstream& operator<<( std::ios (*__pf)( std::ios& ) ) const { std::cerr << __pf; return *this; }
  42.         const wvdebugstream& operator<<( std::ios_base& (*__pf) ( std::ios_base& ) ) const { std::cerr << __pf; return *this; }
  43. #endif
  44.         const wvdebugstream& operator<<( long l ) const { std::cerr << l; return *this; }
  45.         const wvdebugstream& operator<<( unsigned long l ) const { std::cerr << l; return *this; }
  46.         const wvdebugstream& operator<<( bool b ) const { std::cerr << b; return *this; }
  47.         const wvdebugstream& operator<<( short s ) const { std::cerr << s; return *this; }
  48.         const wvdebugstream& operator<<( unsigned short s ) const { std::cerr << s; return *this; }
  49.         const wvdebugstream& operator<<( int i ) const { std::cerr << i; return *this; }
  50.         const wvdebugstream& operator<<( unsigned int i ) const { std::cerr << i; return *this; }
  51.         const wvdebugstream& operator<<( double d ) const { std::cerr << d; return *this; }
  52.         const wvdebugstream& operator<<( float f ) const { std::cerr << f; return *this; }
  53.         const wvdebugstream& operator<<( long double d ) const { std::cerr << d; return *this; }
  54.         const wvdebugstream& operator<<( const void* cv ) const { std::cerr << cv; return *this; }
  55. #if defined(__GNUC__) && __GNUC__ < 3
  56.         const wvdebugstream& operator<<( streambuf* s ) const { std::cerr << s; return *this; }
  57. #else
  58.         const wvdebugstream& operator<<( std::basic_streambuf<char>* s ) const { std::cerr << s; return *this; }
  59. #endif
  60.         const wvdebugstream& operator<<( signed char c ) const { std::cerr << c; return *this; }
  61.         const wvdebugstream& operator<<( unsigned char c ) const { std::cerr << c; return *this; }
  62.         const wvdebugstream& operator<<( const char* s ) const { std::cerr << s; return *this; }
  63.         const wvdebugstream& operator<<( const std::string& s ) const { std::cerr << s; return *this; }
  64.     };
  65.  
  66.  
  67.     class wvnodebugstream
  68.     {
  69.     public:
  70. #if defined(__GNUC__) && __GNUC__ < 3
  71.         const wvnodebugstream& operator<<( ostream& (*__pf)( ostream& ) ) const { std::cerr << __pf; return *this; }
  72.         const wvnodebugstream& operator<<( ios (*__pf)( ios& ) ) const { std::cerr << __pf; return *this; }
  73. #else
  74.         const wvnodebugstream& operator<<( std::basic_ostream<char>& (*__pf)( std::basic_ostream<char>& ) ) const { return *this; }
  75.         const wvnodebugstream& operator<<( std::ios (*__pf)( std::ios& ) ) const { return *this; }
  76.         const wvnodebugstream& operator<<( std::ios_base& (*__pf) ( std::ios_base& ) ) const { return *this; }
  77. #endif
  78.         const wvnodebugstream& operator<<( long ) const { return *this; }
  79.         const wvnodebugstream& operator<<( unsigned long ) const { return *this; }
  80.         const wvnodebugstream& operator<<( bool ) const { return *this; }
  81.         const wvnodebugstream& operator<<( short ) const { return *this; }
  82.         const wvnodebugstream& operator<<( unsigned short ) const { return *this; }
  83.         const wvnodebugstream& operator<<( int ) const { return *this; }
  84.         const wvnodebugstream& operator<<( unsigned int ) const { return *this; }
  85.         const wvnodebugstream& operator<<( double ) const { return *this; }
  86.         const wvnodebugstream& operator<<( float ) const { return *this; }
  87.         const wvnodebugstream& operator<<( long double ) const { return *this; }
  88.         const wvnodebugstream& operator<<( const void* ) const { return *this; }
  89. #if defined(__GNUC__) && __GNUC__ < 3
  90.         const wvnodebugstream& operator<<( streambuf* ) const { return *this; }
  91. #else
  92.         const wvnodebugstream& operator<<( std::basic_streambuf<char>* ) const { return *this; }
  93. #endif
  94.         const wvnodebugstream& operator<<( signed char ) const { return *this; }
  95.         const wvnodebugstream& operator<<( unsigned char ) const { return *this; }
  96.         const wvnodebugstream& operator<<( const char* ) const { return *this; }
  97.         const wvnodebugstream& operator<<( const std::string& ) const { return *this; }
  98.     };
  99.  
  100. #ifdef NDEBUG
  101.     typedef wvnodebugstream wvlogstream;
  102. #else
  103.     typedef wvdebugstream wvlogstream;
  104. #endif
  105.  
  106.     extern const wvlogstream wvlog;
  107.  
  108. } // wvWare
  109.  
  110. #endif // WVLOG_H
  111.